package org.feit.findword;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;

public class Help extends Activity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.help_view);
		setTitle(String.format("%s - %s", getString(R.string.app_name), getString(R.string.help)));
        final String mimeType = "text/html";
        final String encoding = "utf-8";
        
        WebView webView;
        webView = (WebView)findViewById(R.id.help);
        webView.loadData(readHelp(), mimeType, encoding);
	}
	

	private String readHelp() {
		InputStreamReader isr = new InputStreamReader(getResources()
				.openRawResource(R.raw.help));
		BufferedReader bis = new BufferedReader(isr);
		String line;
		StringBuilder sb = new StringBuilder();

		try {
			while ((line = bis.readLine()) != null) {
				sb.append(line);
			}
		} catch (IOException e) {
			//Should not happen.
			e.printStackTrace();
		}
		return sb.toString();
	}
}
